/**
 * Copyright by www.tienon.com
 * All right reserved.
 */
package com.app.oasystem.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @author zhangbaobing
 * @Description StringUtil
 * @data 2021/04/20
 */
public class StringUtil {

	/**
	 * 判断字符串是否有值，且不为"null"字符串
	 * 
	 * @param str
	 * @return
	 * @return boolean 返回类型
	 */
	public static boolean hasText(String str) {
		return str != null && str.trim().length() > 0 && !str.equalsIgnoreCase("null");
	}

	/**
	 * 判断参数不为null
	 * 
	 * @param obj
	 * @return
	 * @return boolean 返回类型
	 */
	public static boolean hasObj(Object obj) {
		return obj != null;
	}

	/**
	 * 格式化字符串 例：formateString("xxx{0}bbb",1) = xxx1bbb
	 * 
	 * @param str
	 * @param params
	 * @return
	 */
	public static String formateString(String str, String... params) {
		for (int i = 0; i < params.length; i++) {
			str = str.replace("{" + i + "}", params[i] == null ? "" : params[i]);
		}
		return str;
	}

	/**
	 * 得到当前日期字符串
	 * 
	 * @param format
	 *            String 格式字符串
	 * @return String
	 */
	public static String getCntDtStr(String format) {
		SimpleDateFormat dtFmt = new SimpleDateFormat(format);
		String nowDtStr = dtFmt.format(Calendar.getInstance().getTime());
		return nowDtStr;
	}
}
